package com.wyh.service.serviceImpl.gfiveImpl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wyh.common.result.FindAccountResult;
import com.wyh.common.result.SysAccountManagementResult;
import com.wyh.domain.po.gfive.PageHelper;
import com.wyh.domain.po.gfive.User;
import com.wyh.mapper.gfivemapper.OrganizationMapper;
import com.wyh.service.gfive.UserService;
import com.wyh.mapper.gfivemapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author KmJHHhhhR
* @description 针对表【user(用户表)】的数据库操作Service实现
* @createDate 2024-05-20 15:03:04
*/
@Service
@Slf4j
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
    implements UserService{

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private OrganizationMapper organizationMapper;
    @Override
    public List<SysAccountManagementResult> findAll(PageHelper pageHelper) {
        int currentPage = (pageHelper.getCurrentPage() - 1) * pageHelper.getPageSize();
        pageHelper.setCurrentPage(currentPage);
        return userMapper.findAll(pageHelper);
    }

    @Override
    public User findByUsername(String username) {
        return userMapper.selectByUsername(username);
    }

    @Override
    public String selectUserTelephoneById(int id) {
        String tel = String.valueOf(userMapper.selectUserTelephoneById(id));
        return tel;
    }

    @Override
    public int resetPassword(User user) {
        return userMapper.restPassword(user);
    }

    @Override
    public int saveAccount(User user) {
        return userMapper.saveAccount(user);
    }

    @Override
    public User findUserId(User user) {
        return userMapper.findUserId(user);
    }

    @Override
    public List<User> findAccountByOrganization(int organization) {
        return userMapper.findAccountByOrganization(organization);
    }

    @Override
    public List<FindAccountResult> findUsers(FindAccountResult findAccountResult) {

        int currentPage = (findAccountResult.getCurrentPage() - 1) * findAccountResult.getPageSize();
        findAccountResult.setCurrentPage(currentPage);

        return userMapper.findUsers(findAccountResult);
    }

    @Override
    public User findById(Integer id) {
        return userMapper.findById(id);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int[] FindUserIds(String account) {
        return userMapper.FindUserIds(account);
    }


}




